from django.template import loader, Context
from django.http import HttpResponse, HttpResponseRedirect
from django.core import serializers
from datetime import datetime, tzinfo, timedelta
import subprocess

def monitor_handler(request):
    ps = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE).communicate()[0]
    processes = ps.split('\n')
    nfields = len(processes[0].split()) - 1
    out = ''
    for row in processes[1:]:
        processcolumns = row.split(None, nfields)
        for pc in processcolumns:
            out += pc
    return HttpResponse(out)